Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
struct System.​Buffers.​ReadOnlySequence<​T>
Assembly: System.Memory
Represents a sequence that can read a sequential series of <typeparamref name="T" /> .
Fields and Constants
public static readonly
ReadOnlySequence<​T>
Empty
Returns an empty <see cref="T:System.Buffers.ReadOnlySequence`1" /> .
Properties
public
SequencePosition
End
Gets the position at the end of the <see cref="T:System.Buffers.ReadOnlySequence`1" /> .
public
ReadOnlyMemory<​T>
First
Gets the <see cref="T:System.ReadOnlyMemory`1" /> from the first segment.
public
ReadOnlySpan<​T>
FirstSpan
Gets the <see cref="T:System.ReadOnlySpan`1" /> from the first segment.
public
bool
IsEmpty
Gets a value that indicates whether the <see cref="T:System.Buffers.ReadOnlySequence`1" /> is empty.
public
bool
IsSingleSegment
Gets a value that indicates whether the <see cref="T:System.Buffers.ReadOnlySequence`1" /> contains a single <see cref="T:System.ReadOnlyMemory`1" /> segment.
public
long
Length
Gets the length of the <see cref="T:System.Buffers.ReadOnlySequence`1" /> .
public
SequencePosition
Start
Gets the position to the start of the <see cref="T:System.Buffers.ReadOnlySequence`1" /> .
Methods
public
Enumerator<​T>
GetEnumerator​()
Returns an enumerator over the <see cref="T:System.Buffers.ReadOnlySequence`1" /> .
Returns Returns an enumerator over the <see cref="T:System.Buffers.ReadOnlySequence`1" /> .
public
long
GetOffset​(SequencePosition position)
Returns the offset of a <paramref name="position" /> within this sequence.
Returns The offset in the sequence.
position
The <see cref="T:System.SequencePosition" /> of which to get the offset.
public
SequencePosition
GetPosition​(long offset)
Returns a new <see cref="T:System.SequencePosition" /> at an <paramref name="offset" /> from the start of the sequence.
Returns An object representing the sequence position that starts at the specified <paramref name="offset" /> from the start of the sequence.
offset
The offset from the start of the sequence.
public
SequencePosition
GetPosition​(long offset,
SequencePosition origin)
Returns a new <see cref="T:System.SequencePosition" /> starting at the specified offset from the <paramref name="origin" /> position.
Returns An object representing the sequence position that starts at the <paramref name="offset" /> position of the specified <paramref name="origin" /> position object.
offset
The offset from the specified <paramref name="origin" /> sequence position.
origin
A sequence position representing the point from which to initiate the offset.
public
ReadOnlySequence<​T>
Slice​(int start,
int length)
Forms a slice out of the current <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at <paramref name="start" /> , with <paramref name="length" /> items.
Returns A slice that consists of <paramref name="length" /> elements from the current instance starting at index <paramref name="start" /> .
start
The index at which to begin this slice.
length
The length of the slice.
public
ReadOnlySequence<​T>
Slice​(int start,
SequencePosition end)
Forms a slice out of the current <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at <paramref name="start" /> and ending at <paramref name="end" /> (exclusive).
Returns A slice that consists of items from the <paramref name="start" /> index to, but not including, the <paramref name="end" /> sequence position in the current read-only sequence.
start
The index at which to begin this slice.
end
The end (exclusive) <see cref="T:System.SequencePosition" /> of the slice.
public
ReadOnlySequence<​T>
Slice​(long start)
Forms a slice out of the current <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at a specified index and continuing to the end of the read-only sequence.
Returns A slice starting at index <paramref name="start" /> and continuing to the end of the current read-only sequence.
start
The start index at which to begin this slice.
public
ReadOnlySequence<​T>
Slice​(long start,
long length)
Forms a slice out of the given <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at <paramref name="start" /> , with <paramref name="length" /> items.
Returns A slice that consists of <paramref name="length" /> elements from the current instance starting at index <paramref name="start" /> .
start
The index at which to begin this slice.
length
The length of the slice.
public
ReadOnlySequence<​T>
Slice​(long start,
SequencePosition end)
Forms a slice out of the current <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at <paramref name="start" /> and ending at <paramref name="end" /> (exclusive).
Returns A slice that consists of items from the <paramref name="start" /> index to, but not including, the <paramref name="end" /> sequence position in the current read-only sequence.
start
The index at which to begin this slice.
end
The end (exclusive) of the slice.
public
ReadOnlySequence<​T>
Slice​(SequencePosition start)
Forms a slice out of the current <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at a specified sequence position and continuing to the end of the read-only sequence.
Returns A slice starting at sequence position <paramref name="start" /> and continuing to the end of the current read-only sequence.
start
The starting (inclusive) <see cref="T:System.SequencePosition" /> at which to begin this slice.
public
ReadOnlySequence<​T>
Slice​(SequencePosition start,
int length)
Forms a slice out of the current <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at <paramref name="start" /> , with <paramref name="length" /> items.
Returns A slice that consists of <paramref name="length" /> elements from the current instance starting at sequence position <paramref name="start" /> .
start
The starting (inclusive) <see cref="T:System.SequencePosition" /> at which to begin this slice.
length
The length of the slice.
public
ReadOnlySequence<​T>
Slice​(SequencePosition start,
long length)
Forms a slice out of the current <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at <paramref name="start" /> , with <paramref name="length" /> items.
Returns A slice that consists of <paramref name="length" /> elements from the current instance starting at sequence position <paramref name="start" /> .
start
The starting (inclusive) <see cref="T:System.SequencePosition" /> at which to begin this slice.
length
The length of the slice.
public
ReadOnlySequence<​T>
Slice​(SequencePosition start,
SequencePosition end)
Forms a slice out of the current <see cref="T:System.Buffers.ReadOnlySequence`1" /> , beginning at <paramref name="start" /> and ending at <paramref name="end" /> (exclusive).
Returns A slice that consists of items from the <paramref name="start" /> sequence position to, but not including, the <paramref name="end" /> sequence position in the current read-only sequence.
start
The starting (inclusive) <see cref="T:System.SequencePosition" /> at which to begin this slice.
end
The ending (exclusive) <see cref="T:System.SequencePosition" /> of the slice.
public
string
ToString​()
Returns a string that represents the current sequence.
Returns A string that represents the current sequence.
public
bool
TryGet​(SequencePosition& position,
ReadOnlyMemory`1& memory,
bool advance = true)
protected
void
Finalize​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object